package com.cgtong.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.cgtong.android.R;
import com.cgtong.android.adapter.AvatarAdapter;
import com.cgtong.android.base.BaseActivity;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;
import butterknife.OnClick;

/*
 * 头像设置
 */
public class MyAvatarActivity extends BaseActivity {

    @BindView(R.id.title_center_txt)
    TextView title_center_txt;
    @BindView(R.id.gv_avatar)
    GridView gv_avatar;

    private AvatarAdapter mAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_my_avatar;
    }
    @Override
    public void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        title_center_txt.setText(getString(R.string.txt_avatar_title));
        mAdapter = new AvatarAdapter(this);
        gv_avatar.setAdapter(mAdapter);
        gv_avatar.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent();
                intent.putExtra("avasterid", i+1);
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("头像设置");
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("头像设置");
        MobclickAgent.onPause(this);
    }

    @OnClick(R.id.title_left_txt)
    public void onViewClicked(View view) {
        finish();
    }
}
